/**
* @class FB_Persona_GUI_search
* @author  Alexei Bratuhin
* @description simple interface class for defining three tags:
*	tag1: wished area of work
*	tag2: it experience
*	tag3: list of further comma-separated, comma-ending tags, that might be helpful
**/

package org.abratuhi.fbpersona.src.gui;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.abratuhi.fbpersona.src.model.FB_Persona_Client;
import org.abratuhi.fbpersona.src.util.string.FB_Persona_StringIO;

@SuppressWarnings("serial")
public class FB_Persona_GUI_search extends JPanel implements ActionListener{
	
	FB_Persona_Client c;
	FB_Persona_GUI root;
	
	JTextField jtf_area = new JTextField("area"); //tag1: "xxx"
	JTextField jtf_exp = new JTextField("it expirience"); //tag2: "novice/medium/expert"
	JTextField jtf_tagcloud = new JTextField("tagcloud"); //tag3: "xxx, qqq, rrr,"
	JButton jb_search = new JButton("Search");
	
	public FB_Persona_GUI_search(FB_Persona_GUI r, FB_Persona_Client c){
		super();
		this.root = r;
		this.c = c;
		setLayout(new GridLayout(1,4,0,0));
		setVisible(true);
		add(jtf_area);
		add(jtf_exp);
		add(jtf_tagcloud);
		add(jb_search);
		jb_search.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals(jb_search.getActionCommand())){
			String res =c.search(jtf_area.getText(), jtf_exp.getText(), FB_Persona_StringIO.String2ArrayOfString(jtf_tagcloud.getText(), ","));
			root.list.jta_result.setText(res);
		}
	}

}
